using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SIGCBI.Entities;

namespace SIGCBI.Repository.Mapping
{
    public class GUIA_ENTRADAMap : EntityTypeConfiguration<GUIA_ENTRADA>
    {
        public GUIA_ENTRADAMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(p => p.ID).
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.NroDoc)
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("GUIA_ENTRADA");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Fecha).HasColumnName("Fecha");
            this.Property(t => t.Total).HasColumnName("Total");
            this.Property(t => t.IdArea).HasColumnName("IdArea");
            this.Property(t => t.IdProveedor).HasColumnName("IdProveedor");
            this.Property(t => t.NroDoc).HasColumnName("NroDoc");
            this.Property(t => t.FechaEntrada).HasColumnName("FechaEntrada");
            this.Property(t => t.IngresadoAlmacen).HasColumnName("IngresadoAlmacen");

            // Relationships
            this.HasRequired(t => t.AREA)
                .WithMany(t => t.GUIA_ENTRADA)
                .HasForeignKey(d => d.IdArea)
                .WillCascadeOnDelete(false);

            this.HasRequired(t => t.PROVEEDOR)
                .WithMany(t => t.GUIA_ENTRADA)
                .HasForeignKey(d => d.IdProveedor)
                .WillCascadeOnDelete(false);

        }
    }
}
